#ifndef LOG_COLLECTION_HPP
#define LOG_COLLECTION_HPP

#include "LogCollectionPrivate.hpp"

namespace LogCollector
{
ReturnStatus init();

ReturnStatus deInit();

#define SS_LOG(aLevel, aFmt, ...) \
    Log(aLevel, __FILE__, __LINE__, __func__, aFmt, ##__VA_ARGS__)

#define SS_LOG_DEBUG(aFmt, ...) \
    Log(Severity::Level::DEBUG, __FILE__, __LINE__, __func__, aFmt, ##__VA_ARGS__)

#define SS_LOG_INFO(aFmt, ...) \
    Log(Severity::Level::INFO, __FILE__, __LINE__, __func__, aFmt, ##__VA_ARGS__)

#define SS_LOG_WARNING(aFmt, ...) \
    Log(Severity::Level::WARNING, __FILE__, __LINE__, __func__, aFmt, ##__VA_ARGS__)

#define SS_LOG_ERROR(aFmt, ...) \
    Log(Severity::Level::ERROR, __FILE__, __LINE__, __func__, aFmt, ##__VA_ARGS__)

#define SS_LOG_CRITICAL(aFmt, ...) \
    Log(Severity::Level::CRITICAL, __FILE__, __LINE__, __func__, aFmt, ##__VA_ARGS__)

void Log(Severity::Level aLevel,
    const char* aFile, int aLine, const char* aFunc, const char* aFmt, ...);

ReturnStatus flushLog();

ReturnStatus clearLogFile();

ReturnStatus setServerityLevel(Severity::Level aLevel);

ReturnStatus setMaxFileSize(uint32_t aSize);

ReturnStatus setMaxFileCount(uint8_t aCount);

ReturnStatus setMaxFlushSize(uint8_t aSize);

ReturnStatus setMaxFlushTimeOut(uint16_t aTimeout);

ReturnStatus setIsWriteToJournal(bool aEnable);

ReturnStatus registerUnexpectedExitHandler();

//! 用户可以自己将handler注册到自定义的sigaction处理器中
void unexpectedExitHandler(int aSignal, siginfo_t* aInfo, void* aContext);

} // namespace LogCollector

#endif // LOG_COLLECTION_HPP